package com.ems.mapper;

import com.ems.entity.BatteryTempEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ems.vo.BatteryTempVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 电池电感温度 Mapper 接口
 * </p>
 * @author WuZH
 * @since 2024-04-23
 */
@Mapper
public interface BatteryTempMapper extends BaseMapper<BatteryTempEntity> {

    @Select (value = "SELECT * FROM battery_temp_info bti JOIN (SELECT deviceAddress, max(createTime) AS createTime FROM battery_temp_info GROUP BY deviceAddress) btii\n" +
            "ON bti.deviceAddress=btii.deviceAddress AND bti.createTime=btii.createTime\n" +
            "ORDER BY bti.createTime DESC")
    List<BatteryTempVo> queryList (@Param ("batteryTempVo") BatteryTempVo batteryTempVo);

    @Select (value = "SELECT COUNT(1) FROM battery_temp_info bti")
    Integer queryCount (@Param ("batteryTempVo") BatteryTempVo batteryTempVo);

}
